import requests


def get_comic_data(url, form_data):
    if url is None:
        print("ERROR:\n 'url can not be None'")
        print("local value:\n:url:'{}' form_data:'{}'".format(url, form_data))
        return None
    r = requests.post(url, data=form_data).json()
    if r['code'] == '501':
        data = r['data']
        return data
    else:
        print("ERROR:")
        print("BASE/interface/get_comic_data/get_comic_data()"
              " code '{}', "
              "code_info '{}'".format(r['code'], r['code_info'])
              )
        print("local value:\nurl:'{}'\nform_data:{}".format(url, form_data))
        return None


def get_novels_data(url=None, form_data=None):
    if url is None:
        print("ERROR:\n 'url can not be None'")
        print("local value:\n:url:'{}' form_data:'{}'".format(url, form_data))
        return None
    r = requests.post(url, data=form_data).json()
    if r['code'] == '501':
        return r['data']
    else:
        print("ERROR:")
        print("BASE/interface/get_comic_data/get_comic_data()"
              " code '{}', "
              "code_info '{}'".format(r['code'], r['code_info'])
              )
        print("local value:\nurl:'{}'\nform_data:{}".format(url, form_data))
        return None
